package com.wswy.wzcx.widget.utils;

import android.text.Editable;
import android.text.TextWatcher;

public class MoneyTextWatcher implements TextWatcher {

  @Override
  public void beforeTextChanged(CharSequence s, int start, int count, int after) {

  }

  @Override
  public void onTextChanged(CharSequence s, int start, int before, int count) {

  }

  @Override
  public void afterTextChanged(Editable s) {
    if (s != null) {
      String temp = s.toString();
      int posDot = temp.indexOf(".");
      if (posDot <= 0) {
        return;
      }
      if (temp.length() - posDot - 1 > 2) {
        s.delete(posDot + 3, posDot + 4);
      }
    }
  }
}
